﻿@{
    ViewBag.Title = "OrganizationAdd";
}
@section head
{
    <script src="@Url.Content("~/ScriptPlugin/validate/validate.js")"></script>
    <link href="@Url.Content("~/ScriptPlugin/validate/validate.css")" rel="stylesheet" />
    <script type="text/javascript" src="@Url.Content("~/Scripts/form2json.js")"></script>
}
<form action="">
    <div class="content-form">
        <table class="content-table">
            <tr>
                <th><span>机构名称</span></th>
                <td>
                    <input type="text" maxlength="80" data-validate-option="isNull" id="Name" name="Name" />
                </td>
                <th>上级机构</th>
                <td>
                    <input type="hidden" id="ParentOrganizationId" name="ParentOrganizationId" />
                    <input type="text" id="ParentOrganizationName" name="ParentOrganizationName" maxlength="80" 
                           readonly="readonly" class="p-icon-right p-icon-business" onclick="getParent(this)" />
                </td>
            </tr>
            <tr>
                <th><span>机构编码</span></th>
                <td><input type="text" maxlength="10" data-validate-option="isNull" id="Code" name="Code" /></td>
                <th>排序号</th>
                <td><input type="text" value="0" id="Order" name="Order" onkeypress="K.OnlyNum()" /></td>
            </tr>
            <tr>
                <th>备注</th>
                <td colspan="3">
                    <input type="text" maxlength="500" id="Remark" name="Remark" />
                </td>
            </tr>
        </table>
    </div>
</form>
@section foot
{
    <script type="text/javascript">
       function SaveData(index) {
           if (K.Validate()) {
               var dto = KingsSharp.Form2Json();
               K.AjaxJson("@Url.Content("~/Sys/Organization/OrganizationInsert")", { dtos: dto }, function (result) {
                   parent.K.layer.callback(index, result, dto);
                   parent.K.layer.close(index);
               });
           }
       }
        function getParent(obj)
        {
            K.layer.iframe({
                title: "@Html.GetLayerTitle(LayerIcon.Details,"机构选择")",
                content: "@Url.Content("~/Sys/Organization/OrganizationTree")",
                maxmin: true,
                area:["360px","300px"],
                callback:function(node)
                {
                    $("#ParentOrganizationName").val(node.name);
                    $("#ParentOrganizationId").val(node.id);
                }
            });
        }
    </script>
}